package com.mdd.front.service.impl.yangyangLeadingEnterprise;

import com.mdd.common.entity.yangyangLeadingEnterprise.TAppEnterpriseQualificationRecord;
import com.mdd.common.entity.yangyangLeadingEnterprise.common.JsonReturn;
import com.mdd.common.entity.yangyangLeadingEnterprise.param.EnterprisePolicySubsidiesRecordParam;
import com.mdd.common.mapper.yangyangLeadingEnterprise.TAppEnterpriseMapper;
import com.mdd.common.mapper.yangyangLeadingEnterprise.TAppEnterpriseQualificationRecordMapper;
import com.mdd.common.mapper.yangyangLeadingEnterprise.TAppUserMapper;
import com.mdd.front.service.yangyangLeadingEnterprise.ITAppEnterpriseQualificationRecordService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

/**
 * 企业资质申请记录实现类
 * @author LikeAdmin
 */
@Service
public class TAppEnterpriseQualificationRecordServiceImpl implements ITAppEnterpriseQualificationRecordService {
        
    @Resource
    TAppEnterpriseQualificationRecordMapper tAppEnterpriseQualificationRecordMapper;

    @Resource
    TAppUserMapper appUserMapper;

    @Resource
    TAppEnterpriseMapper appEnterpriseMapper;
    /**
     * 企业资质申请记录新增
     * @param param
     * @return
     */
    @Override
    public String addEnterpriseQualificationRecord(EnterprisePolicySubsidiesRecordParam param) {
        Long userId = param.getUserId();
        Integer enterpriseId = param.getEnterpriseId();
        if (userId == null || enterpriseId == null){
            return JsonReturn.fail("必传参数不能为空！",40001).toJsonStr();
        }
        TAppEnterpriseQualificationRecord record = new TAppEnterpriseQualificationRecord();
        record.setUserId(userId);
        record.setUserName(appUserMapper.selectById(userId).getNickname());
        record.setEnterpriseId(enterpriseId);
        record.setEnterpriseName(appEnterpriseMapper.selectById(enterpriseId).getEnterpriseName());
        record.setStatus(1);
        record.setCreateTime(new Date());
        record.setUpdateTime(new Date());
        tAppEnterpriseQualificationRecordMapper.insert(record);
        return JsonReturn.success().toJsonStr();
    }
}
